//
//  SFNavigationBarData.m
//  SFNavigationBarManager_Example
//
//  Created by shen on 2021/11/17.
//  Copyright © 2021 yangshen. All rights reserved.
//

#import "SFNavigationBarData.h"

@implementation SFNavigationBarData

+ (UIColor *)barTintColorWithStyle:(SFNavigationBarStyle)style {
    switch (style) {
        case SFNavigationBarStyleWhite:
            return [UIColor whiteColor];
            break;
        case SFNavigationBarStyleCyan:
            return [UIColor cyanColor];
            break;
        case SFNavigationBarStyleYellow:
            return [UIColor yellowColor];
            break;
        case SFNavigationBarStyleOrange:
            return [UIColor orangeColor];
            break;
        case SFNavigationBarStyleLightGray:
            return [UIColor lightGrayColor];
            break;
        default:
            return nil;
            break;
    }
}

+ (UIImage *)barImageWithStyle:(SFNavigationBarStyle)style {
    switch (style) {
        case SFNavigationBarStyleWhite:
            return [UIImage imageWithColor:[UIColor whiteColor]];
            break;
        case SFNavigationBarStyleCyan:
            return [UIImage imageWithColor:[UIColor cyanColor]];
            break;
        case SFNavigationBarStyleYellow:
            return [UIImage imageWithColor:[UIColor yellowColor]];
            break;
        case SFNavigationBarStyleOrange:
            return [UIImage imageWithColor:[UIColor orangeColor]];
            break;
        case SFNavigationBarStyleLightGray:
            return [UIImage imageWithColor:[UIColor lightGrayColor]];
            break;
        case SFNavigationBarStyleTransparent:
            return [UIImage new];
        default:
            return nil;
            break;
    }
}

+ (NSString *)nameWithStyle:(SFNavigationBarStyle)style {
    switch (style) {
        case SFNavigationBarStyleWhite:
            return @"White";
            break;
        case SFNavigationBarStyleCyan:
            return @"Cyan";
            break;
        case SFNavigationBarStyleYellow:
            return @"Yellow";
            break;
        case SFNavigationBarStyleOrange:
            return @"Orange";
            break;
        case SFNavigationBarStyleLightGray:
            return @"Light Gray";
            break;
        case SFNavigationBarStyleTransparent:
            return @"Transparent";
        case SFNavigationBarStyleNoValue:
            return @"No Value";
        default:
            return nil;
            break;
    }
}

@end

@implementation UIImage (FromColor)

+ (UIImage *)imageWithColor:(UIColor *)color {
    CGRect r = CGRectMake(0, 0, 1, 1);
    UIGraphicsBeginImageContext(r.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, r);
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return img;
}

@end
